<?php
class PNSubCategoryArray extends PNObjectExArray {
  function PNSubCategoryArray($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'innoforum_subcategory';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';

    $this->_objJoin[]     = array ( 'join_table'  =>  'innoforum_category',
                            'join_field'          =>  array('name'),
                            'object_field_name'   =>  array('category_name'),
                            'compare_field_table' =>  'category_id',
                            'compare_field_join'  =>  'id');

    $this->_init($init, $where);
  }


  function genSort(){
    return " ORDER BY category_id, name ASC";
  }

  function genFilter(){
    $category_id  = FormUtil::getPassedValue ('category_id', false);

    $wheres = array();

    //filter by selector
    if ($category_id && intval($category_id)) $wheres[] = "scy_category_id ='$category_id'";

    return implode(' AND ', $wheres) ;
  }

}